class Solution(object):
    def groupAnagrams(self, strs):
        """
        :type strs: List[str]
        :rtype: List[List[str]]
        """
        m = {}
        for s in strs:
            sk = "".join(sorted(s))
            if sk not in m:
                m[sk] = []
            m[sk].append(s)
        return list(m.values())

s = Solution()
strs = ["eat", "tea", "tan", "ate", "nat", "bat"]
result = s.groupAnagrams(strs)
print(result)

strs = [""]
result = s.groupAnagrams(strs)
print(result)

strs = ["a"]
result = s.groupAnagrams(strs)
print(result)
